package cn.acewill.yxd.yunxundian.Api;

import com.alibaba.fastjson.JSON;

import org.xutils.DbManager;
import org.xutils.ex.DbException;
import org.xutils.x;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import cn.acewill.yxd.yunxundian.BaseActivity;
import cn.acewill.yxd.yunxundian.YXDAPP;
import cn.acewill.yxd.yunxundian.model.SignUpInfo;
import cn.acewill.yxd.yunxundian.pubClass.OkHttpManger;
import cn.acewill.yxd.yunxundian.pubClass.pubClass;
import cn.acewill.yxd.yunxundian.ui.MainActivity;

/**
 * Created by xxx on 2018/3/1.
 * 用于用户签到签出
 */

public class SignApi {
    protected YXDAPP yxdapp=new YXDAPP();
    protected DbManager db = x.getDb(yxdapp.getDaoConfig());
    private static SignApi instance;
    public SignApi(){

    }
    public static SignApi getInstance(){
        if (instance==null){
            instance = new SignApi();
        }
        return instance;
    }

    /**
     * 仅用于邮件发送完成后的签出，不支持离线
     * @param info 本地敲到数据
     */
    public void SignOutByNet(final SignUpInfo info){
        Map<String,String> map=new HashMap<>();
        map.put("task","signoutsync");
        map.put("siJson", JSON.toJSONString(info));
        try {
            OkHttpManger.getInstance().postAsync(pubClass.Server_namehzm, new OkHttpManger.MyCallback() {
                @Override
                public void onSuccess(String result) {
                    String[] array=result.split("\\|");
                    if(array[0].equals("200")) { //迁出成功
                            MainActivity.signId = 0;
                    }
                }

                @Override
                public void onFailture() {

                }
            },map);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }




}
